@echo off


:: Set working dir
cd %~dp0 & cd ..

set PAUSE_ERRORS=1

call bat\SetupSDK.bat
call bat\SetupApp.bat

set OUTPUT=%AIR_PATH%\%AIR_NAME%%AIR_TARGET%.air

echo Updating Sigh File...

copy %CERT_FILE% "bat\%CERT_NAME%_old.p12" /Y

call adt -certificate -cn %CERT_NAME% 2048-RSA %CERT_FILE% %CERT_PASS%

echo Sighing Air File...

call adt -migrate %SIGNING_OPTIONS% %OUTPUT% "%OUTPUT%_newSigh.air"
if errorlevel 1 goto failed
goto end

:failed
echo AIR setup creation FAILED.
echo.
echo Troubleshooting: 
echo - verify AIR SDK target version in %APP_XML%
echo.
if %PAUSE_ERRORS%==1 pause
exit

:end
echo Package Successed.
echo.

pause